#ifndef spi_h_
#define spi_h_

#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"
#include "stm32f4xx_gpio.h"
#include "stm32f4xx_spi.h"
#include "stm32f4xx_tim.h"
#include "FlightDataStruct.h"

#define LIS302DL_FLAG_TIMEOUT 10000;




int LIS302DL_ReadX();
int LIS302DL_ReadY();
int LIS302DL_ReadZ();
void UpdateSpiState(struct FlightDataStruct* state);
void init_Spi(void);
void LIS302DL_Init();
unsigned char LIS302DL_SendByte(u8 byte);
int LIS302DL_GetByte();
void LIS302DL_Write(u8 REG, u8 *DATA, u8 count);
void LIS302DL_Read(u8 REG, u8 *DATA, u8 count);
void LIS302DL_ReadACC(int32_t* out);
void LIS302DL_ReadACCY(int32_t* out);
unsigned int abs(u32 n);

#endif
